package com.mqttProvider.controller;

import com.mqttProvider.config.MqttConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenming
 * @description
 * @create: 2022-11-24
 */
@RestController
public class MqttProvider {

    @Autowired
    private MqttConfig mqttConfig;

    @GetMapping("/test")
    public String sendMessage(String topic, String message, int qos, boolean retained) {
        mqttConfig.publish(topic, message, qos, retained);
        return "发送成功";
    }

    @GetMapping("/consumer")
    public String consumer(String topic, int qos) {
        mqttConfig.subscribe(topic,qos);
        return "发送成功";
    }

}
